home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / fonttools / fonttest.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  4KB  |  191 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    fonttest - 
  19.  *        Test object fonts.
  20.  *
  21.  *                Paul Haeberli - 1990
  22.  *
  23.  */
  24. #include "gl.h"
  25. #include "device.h"
  26. #include "stdio.h"
  27. #include "objfnt.h"
  28.  
  29. float fgetmousex();
  30. float fgetmousey();
  31. float spin, warp;
  32.  
  33. int doaa, dofill;
  34. char ofname[256];
  35. char mfname[256];
  36.  
  37. main(argc,argv)
  38. int argc;
  39. char **argv;
  40. {
  41.     short val;
  42.     int menu;
  43.  
  44.     if(argc<2) {
  45.     fprintf(stderr,"usage: fonttest: Font-Name\n");
  46.     exit(1);
  47.     }
  48.     keepaspect(85,110);
  49.     winopen("fonttest");
  50.     subpixel(1);
  51.     RGBmode();
  52.     doublebuffer();
  53.     gconfig();
  54.     menu = defpup("fonttest %t|toggle fill|toggle smooth");
  55.     sprintf(ofname,"%s.of",argv[1]);
  56.     sprintf(mfname,"%s.mf",argv[1]);
  57.     makeframe();
  58.     qdevice(LEFTMOUSE);
  59.     qdevice(MIDDLEMOUSE);
  60.     qdevice(MENUBUTTON);
  61.     while(1) {
  62.     switch(qread(&val)) {
  63.         case REDRAW:
  64.         makeframe();
  65.         break;
  66.         case LEFTMOUSE:
  67.         while(getbutton(LEFTMOUSE)) {
  68.             spin = fgetmousex();
  69.             warp = fgetmousey();
  70.             makeframe();
  71.         }
  72.         break;
  73.         case MIDDLEMOUSE:
  74.         if(val)
  75.             savergbwindow("save.rgb");
  76.         break;
  77.         case RIGHTMOUSE:
  78.         if(val) {
  79.             switch(dopup(menu)) {
  80.             case 1:
  81.                 dofill = 1-dofill;
  82.                 makeframe();
  83.                 break;
  84.             case 2:
  85.                 doaa = 1-doaa;
  86.                 makeframe();
  87.                 break;
  88.             }
  89.         }
  90.     }
  91.     }
  92. }
  93.  
  94. makeframe()
  95. {
  96.     int i;
  97.  
  98.     reshapeviewport();
  99.     ortho2(0.0,72*8.5,0.0,72*11.0);
  100.  
  101.     cpack(0x00ffffff);
  102.     clear();
  103.     cpack(0xff000000);
  104.  
  105.     if(doaa) {
  106.     if(dofill) {
  107.         fontname(mfname);
  108.         drawit();
  109.     }
  110.     blendfunction(BF_SA,BF_MSA);
  111.     linesmooth(SML_ON);
  112.     fontname(ofname);
  113.     drawit();
  114.     blendfunction(BF_ONE,BF_ZERO);
  115.     linesmooth(SML_OFF);
  116.     } else {
  117.     if(dofill) 
  118.         fontname(mfname);
  119.     else 
  120.         fontname(ofname);
  121.     pushmatrix();
  122.     for(i=0; i<1; i++) {
  123.         drawit();
  124.         translate(1.0,1.0,0.0);
  125.     }
  126.     popmatrix();
  127.  
  128.     }
  129.     swapbuffers();
  130. }
  131.  
  132. dowarp()
  133. {
  134.     float s;
  135.  
  136.     s = 1.0-warp;
  137.     scale(s,s,s);
  138. }
  139.  
  140. drawit(name)
  141. {
  142.     pushmatrix();
  143.     rot(20.0*spin,'z');
  144.  
  145.     fontsetsize(0.75);
  146.  
  147.     scale(72.0,72.0,0.0);
  148.  
  149.     translate(0.0,9.0,0.0);
  150.     dowarp();
  151.     fontmoveto(4.0,0.0);
  152.     fontcentershow("AaBbCcDdEeFf");
  153.  
  154.     translate(0.0,-1.0,0.0);
  155.     dowarp();
  156.     fontmoveto(4.0,0.0);
  157.     fontcentershow("GgHhIiJjKkLl");
  158.  
  159.     translate(0.0,-1.0,0.0);
  160.     dowarp();
  161.     fontmoveto(4.0,0.0);
  162.     fontcentershow("MmNnOoPpQqRr");
  163.  
  164.     translate(0.0,-1.0,0.0);
  165.     dowarp();
  166.     fontmoveto(4.0,0.0);
  167.     fontcentershow("SsTtUuVvWwXx");
  168.  
  169.     translate(0.0,-1.0,0.0);
  170.     dowarp();
  171.     fontmoveto(4.0,0.0);
  172.     fontcentershow("YyZz");
  173.  
  174.     translate(0.0,-1.0,0.0);
  175.     dowarp();
  176.     fontmoveto(4.0,0.0);
  177.     fontcentershow("1234567890");
  178.  
  179.     translate(0.0,-1.0,0.0);
  180.     dowarp();
  181.     fontmoveto(4.0,0.0);
  182.     fontcentershow("~!@#$%^&*\(\)_+,.");
  183.  
  184.     translate(0.0,-1.0,0.0);
  185.     dowarp();
  186.     fontmoveto(4.0,0.0);
  187.     fontcentershow("-={}[]|\\:;\"'<>?");
  188.  
  189.     popmatrix();
  190. }
  191.